//
//  ZWColorLabel.m
//  08.音乐播放器
//
//  Created by mac on 16/3/15.
//  Copyright © 2016年 itheima. All rights reserved.
//

#import "ZWColorLabel.h"

@implementation ZWColorLabel

- (void)setProgress:(CGFloat)progress{

    _progress = progress;
    //重绘
    [self setNeedsDisplay];
}
//如果外界没有赋值给颜色,则采用默认颜色
- (UIColor *)currentColor{

    if (_currentColor == nil) {
        _currentColor = [UIColor blueColor];
    }
    return _currentColor;
}


// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
    [super drawRect:rect];
    
    [self.currentColor set];
    
    rect.size.width *= self.progress;
    //图形混合模式
    UIRectFillUsingBlendMode(rect, kCGBlendModeSourceIn);
    
}


@end
